<template>
  <div class="lb-top-nav">
    <div @click="goBack" class="nav-item">
      <i class="iconfont iconjiantou_zuo" v-if="isBack"></i
      >{{ $t('menu.' + title) }}
    </div>
  </div>
</template>

<script>
export default {
  name: 'lbTitle',
  props: {
    isBack: {
      type: Boolean,
      default: false
    }
  },
  data () {
    return {
      title: ''
    }
  },
  created () {
    this.title = this.$route.meta.menuName
  },
  watch: {
    $route (val) {
      this.title = val.meta.menuName
    }
  },
  methods: {
    goBack () {
      if (!this.isBack) return
      this.$router.back(-1)
    }
  }
}
</script>

<style lang="scss" scoped>
.lb-top-nav {
  width: 100%;
  height: 60px;
  border-bottom: 1px solid #e1e1e1;
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 14px;
  white-space: nowrap;
  margin-bottom: 20px;
  .nav-item {
    height: 60px;
    padding: 0 20px;
    line-height: 60px;
    cursor: pointer;
    &::after {
      position: absolute;
      content: '';
      width: 0%;
      bottom: 0;
      left: 0;
      right: 0;
      margin: auto;
      height: 0px;
      background: $themeColor;
      transform: all 0.3 linear;
    }
  }
}
</style>
